<?php
ob_start();
session_start();
include "inc/conn.php";
$tts = date("YmdHis",time());

?>
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
<meta name="apple-mobile-web-app-capable" content="yes" />
<title>后台管理</title>
<meta name="author" content="andy - vip@d163.net">
<meta name="copyright" content="www.d163.net">
<link href="https://lib.baomitu.com/twitter-bootstrap/4.0.0/css/bootstrap.min.css" rel="stylesheet">
<link rel="stylesheet" href="http://at.alicdn.com/t/font_374778_ufdzobu4bkh.css">
<link href="inc/css/wap.css?v=<?php echo $tts;?>" rel="stylesheet" type="text/css" />
<script src="inc/js/ajax_wap.js?v=<?php echo $tts;?>" type="text/javascript"></script>
<style>
	.myform button[type='submit'] {margin-top: 10px; }
	.myform .form-group {color: #ffffff; }
	.main{padding-left: 15px;padding-right: 15px;}
	.mod_list{position:relative;display:flex;flex-wrap:wrap;}
	.mod_list>.mod_item{flex-basis:33.3333%;}
	.mod_list>.mod_item a{position:relative;display:block;padding:0 0 15px 0;color:#fff;text-align:center;}
	.mod_list>.mod_item a>*{display:block;}
	.mod_list>.mod_item a span{color:#fff;}
	.mod_list>.mod_item a:before{position:absolute;top:0;right:0;bottom:0;width:1px;background-color:#ffd5c8;content:" ";}
	.mod_list>.mod_item a:after{position:absolute;right:0;bottom:0;left:0;height:1px;background-color:#ffd5c8;content:" ";}
	.mod_list:before{position:absolute;top:0;right:0;left:0;height:1px;background-color:#ffd5c8;content:" ";}
	.mod_list:after{position:absolute;top:0;bottom:0;left:0;width:1px;background-color:#ffd5c8;content:" ";}
	.index_logo{min-height:50px;text-align: center;color: #fff3cf;padding: 10px 0 15px 0;}
	.mod_list>.mod_item a i.iconfont{font-size:40px;}
	.logo-img {width: 60%; margin-bottom: 20px; }
</style>
</head>
<?php

$root=false;
$username = $_POST['username'];

if(isset($_POST['id']) && $_POST['id']==1){
	    if($_POST['pwd']==$password){
	    	$_SESSION['pwd']=$password;
	    	$pwd = $_SESSION['pwd'];
	    	echo '<p style="color: #fff; background-color: #4CAF50; text-align: center; padding: 14px 0; font-size: 18px; z-index: 1002; position: fixed; width: 100%; top: 0; ">登录成功...</p> 
			<script>
				setTimeout(function(){
					window.location.href="login.php"
				},1500)
			</script>
	    	';
			// header("location:scan.php?v={$tts}");
			// echo "<script>alert('用户[{$username}]登录成功');</script>";

	    } else{echo "<script>alert('密码错误');window.location.href='login.php?c=login';</script>";}
}

?>

<body>

<div class="bgcard"></div>
<?php 
$login_ok = isset($_GET['c']) ? $_GET['c']:"loginok";

if ($_SESSION['pwd']== $password ) { ?>
<div class="main admin_index">
	<div class="index_logo">
		<div class="logo-img mx-auto"><img src="inc/img/logo.png" class="img-fluid"></div>
		<h4>核销、签到系统</h4>
	</div>	
	<div class="mod_list">
		<div class="mod_item">
			<a href="admin.php">
				<i class="iconfont icon-icon_setting"></i>
				<span>基本设置</span>
			</a>
		</div>
		<div class="mod_item">
			<a href="scan.php">
				<i class="iconfont icon-fenlei"></i>
				<span>扫码核销</span>
			</a>
		</div>
		<div class="mod_item">
			<a href="manage.php">
				<i class="iconfont icon-yijianfankui"></i>
				<span>签到统计</span>
			</a>
		</div>
		<div class="mod_item">
			<a href="list.php">
				<i class="iconfont icon-appstore-fill"></i>
				<span>报名统计</span>
			</a>
		</div>
		<div class="mod_item">
			<a href="search.php">
				<i class="iconfont icon-search"></i>
				<span>信息查询</span>
			</a>
		</div>
		<div class="mod_item">
			<a href="add.php">
				<i class="iconfont icon-export"></i>
				<span>数据导入</span>
			</a>
		</div>
	</div>
</div>
<?php } else if($login_ok == "login"){ ?>
<div class="main">
	<div class="qd_text_box">
		<div class="qd_title"><h4>用户登录</h4></div>
		
	</div>
	<form action="login.php" method="post" class="myform">
		<input type="hidden" name="id" value="1">

		<div class="form-group">
			<label for="username">用户名</label>
			<input class="form-control" name="username" type="text" id="username" value="名家居世博园" readonly>
		</div>
		<div class="form-group">
			<label for="pwd">密码</label>
			<input class="form-control" name="pwd" type="password" id="pwd" placeholder="请输入密码">
		</div>
		<button class="btn btn-primary btn-block" type="submit">登 录</button>
	</form>
</div>

<?php } else if($login_ok != "login"){ ?>
<script>
	window.location.href="login.php?c=login";
</script>

<?php  } ?>

</body>
</html>